package system;

import uci.rt.ccr1c.engine.matrix.Mat;

public class SystemEQ
{


	private Mat a;
	private Mat b;
	private Mat solution;

	public SystemEQ(double[][] ad, double[] bd)
	{
		
		this.a = new Mat(ad);
		this.b= new Mat(new double[][]{bd});
	}

	public void solve() throws Exception
	{ 
		if(!checkSolvibility())//linear indipendent
			throw new Exception("the system has no solution or infinite, vectors ARE linear dipendent");
		
		solution= a.inverse().multiplyByTranspose(b);
		
	}

	

	

	private boolean checkSolvibility() throws Exception
	{
		double det=a.det();
		if(det==0.0)
		return false;
		return true;
	}


	public Mat getSolution()
	{
		return solution;
	}

}
